package com.freshcity.page.feiji
{
	import com.freshcity.ILayer;
	import com.freshcity.component.container.Component;
	import com.freshcity.component.guide.GuideTipsManager;
	import com.freshcity.core.BaseHomeWin;
	import com.freshcity.core.OpCodes;
	import com.freshcity.feiji.HomeWin;
	import com.freshcity.utils.GlobalUtil;
	import com.greensock.TweenLite;
	import com.greensock.TweenMax;
	
	import fl.events.ListEvent;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.Dictionary;

	public class FeijiHome extends BaseHomeWin
	{
		private var back:HomeWin;

		public function FeijiHome(parent:ILayer=null, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos,"纸飞机");
			back.tabMenu.addEventListener(ListEvent.ITEM_CLICK, drawContent);
		}

		override protected function initContent(index:int):void
		{
			var c:Component;
			switch (index)
			{
				case 0:
				{
					c=new FeiJiView();
					break;
				}
				case 1:
				{
					c=new FeiJiStatus();
					break;
				}
				case 2:
				{
					c=new FeijiRank();
					break;
				}
				default:
				{
					break;
				}
			}
			c.main=this.main;
			_contains[index]=c;
		}

		override protected function addChildren():void
		{
			super.addChildren();
			back=new HomeWin();
			addChild(back);

			container=back.container;
			container.mouseEnabled=false;
			container.tabEnabled=false;
			
			back.tabMenu.arrBtnLabels=["纸飞机世界","我的纸飞机", "每周明星飞机"];
		}

		override public function destroy():void
		{
			super.destroy();
		}

		override public function hide(event:Event=null):void
		{
			super.hide(event);
		}

		override public function show(event:Event=null):void
		{
			super.show(event);
			back.tabMenu.selectedIndex = 0;
			if(!GlobalUtil.guideIsDone(1)){
				TweenLite.delayedCall(1,onShowGuide);
			}else{
				back.tabMenu.dispatchEvent(new ListEvent(ListEvent.ITEM_CLICK, false, true, 0, 0, 0));
			}
		}
		
		private function forwardPage():void
		{
			main.guideTip.hideGuideTips();
			main.commu.send(OpCodes.GUIDE_DONE, {indexPos:1});
			back.tabMenu.dispatchEvent(new ListEvent(ListEvent.ITEM_CLICK, false, true, 0, 0, 0));
		}
		
		private function onShowGuide():void
		{
			var s:String = "你正在渴望爱情？或者情绪低落？还是迷茫困惑？抑或就是百无聊赖！";
			main.guideTip.getGuideTips(s,onShowGuide2,0,null,false);
		}
		
		private function onShowGuide2():void
		{
			var s:String = "投个纸飞机吧！带着一份闲适的心收获只属于你的关怀与关注。";
			main.guideTip.getGuideTips(s,forwardPage,0,null,false);
		}		
	}
}
